<template>
  <div>
    <el-tabs
      v-model="active"
      type="border-card"
      class="el-tabs--shadowless"
      style="min-height: 86vh"
    >
      <el-tab-pane label="银行" name="first">
        <org-count-panel :agency-type="1"></org-count-panel>
      </el-tab-pane>
      <el-tab-pane label="企业" v-if="!isUserCounty" name="second">
        <org-count-panel :agency-type="2"></org-count-panel>
      </el-tab-pane>
      <el-tab-pane label="政府" name="third">
        <org-count-panel :agency-type="3"></org-count-panel>
      </el-tab-pane>
      <el-tab-pane label="社会组织" v-if="!isUserCounty" name="four">
        <org-count-panel :agency-type="4"></org-count-panel>
      </el-tab-pane>
      <el-tab-pane label="供销社" v-if="!isUserCounty" name="fifth">
        <org-count-panel :agency-type="5"></org-count-panel>
      </el-tab-pane>
      <el-tab-pane label="担保联盟" name="sixth">
        <org-count-credit></org-count-credit>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
<script>
import { mapGetters } from 'vuex'
import { enumFarmType } from '@/credit/plugins/enum'
// import { queryTrouble } from '@vimi/utils-api'
import OrgCountPanel from './OrgCountPanel'
import OrgCountCredit from '@/credit/views/city/org/OrgCountCredit'
export default {
  components: {
    OrgCountPanel,
    OrgCountCredit,
  },
  data() {
    return {
      enumFarmType,
      active: 'first',
      amount: {},
      creditAmount: {},
    }
  },
  computed: {
    ...mapGetters(['clientId', 'user']),
    isUserCounty() {
      return +this.user.orgRegionLever === 3
    },
  },
  created() {
    // this.getAmountData()
    // this.getCreditAmount()
  },
  methods: {
    // handleTabChange() {
    //   this.active === 'sixth' ? this.getCreditAmount() : this.getAmountData()
    // },
    // async getAmountData(name) {
    //   const table = 'credit_agency_total_view_db'
    //   const url = queryTrouble(table, {
    //     groupFields: 'agency_name',
    //     groupFunc: 'SUM(customer_count),SUM(credit_amount)',
    //     agency_name: name,
    //     'service_id.eq': this.clientId
    //   })
    //   const [res] = await this.$utils.promise(this.$api.getDataQuery('credit', table, url))
    //   const data = (res && res.data && res.data.length && res.data[0]) || {}
    //   this.creditAmount.customer = data.p || '0'
    //   this.creditAmount.credit = data.p1 || '0'
    // },
    //   async getCreditAmount(params) {
    //     const table = 'credit_agency_total_view_db'
    //     const url = queryTrouble(table, {
    //       ...params,
    //       groupFields: 'agency_name',
    //       groupFunc: 'SUM(customer_count),SUM(credit_amount)',
    //       'service_id.eq': this.clientId
    //     })
    //     const [res] = await this.$utils.promise(this.$api.getDataQuery('credit', table, url))
    //     const data = (res && res.data && res.data.length && res.data[0]) || {}
    //     this.creditAmount.customer = data.p || '0'
    //     this.creditAmount.credit = data.p1 || '0'
    //   }
  },
}
</script>

<style scoped></style>
